package com.jmuok.web.fff.util;

import java.util.Locale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.NoSuchMessageException;

import com.sun.org.apache.xalan.internal.xsltc.compiler.sym;

@Configurable
public class Messager {

	@Autowired
	private MessageSource ms;

	private static Messager messager;

	private Messager() {
	};

	public String getMessage(String code, Object[] args, Locale locale)
			throws NoSuchMessageException {

		return ms.getMessage(code, args, locale);
	}

	public String getMessage(String code, Object[] args, String defaultMessage,
			Locale locale) {
		return ms.getMessage(code, args, defaultMessage, locale);
	}

	public synchronized static Messager get() {
		if (messager == null) {
			messager = new Messager();
		}
		return messager;
	}

}
